#include<iostream>
#include<string>
using namespace std;

struct free_throws
{
    string name;
    int made;
    int attempts;
    float percent;
};

void display(const free_throws& ft);

void set_pc(free_throws& ft);

free_throws& accumulate(free_throws& target, const free_throws& source);



int main()
{
    free_throws one = {"Ifesla Branch", 13, 14};
    free_throws two = {"Andor Knott", 10, 16};
    free_throws three = {"Minx Max", 7, 9};
    free_throws four = {"Wheel Looper", 5, 9};
    free_throws five = {"Long Long", 6, 14};
    free_throws tearm = {"We Are Tearm", 0, 0};

    free_throws dup;
    set_pc(one);
    display(one);
    accumulate(tearm,one);
    display(tearm);
    display(accumulate(tearm, two));
    accumulate(accumulate(tearm,three),four);
    display(tearm);

    dup = accumulate(tearm, five);
    cout << "\ndisplay tearm:\n";
    display(tearm);
    cout << "\ndisplay dup\n" << endl;
    display(dup);

    set_pc(four);
    accumulate(dup,five) = four;

    cout << "displaying dup after ill-advised assigment\n";
    display(dup);


    return 0;
}

void display(const free_throws& ft)
{
    cout << "name :" << ft.name << endl;
    cout << "made :" << ft.made << endl;
    cout << "attempts:" << ft.attempts << endl;
    cout << "percent:" << ft.percent << endl;
}

void set_pc(free_throws& ft)
{
    if(ft.attempts != 0)
    {
        ft.percent = 100.0f*float(ft.made)/float(ft.attempts);
    }
    else
        ft.percent = 0;

}

free_throws& accumulate(free_throws& target, const free_throws& source)
{
    target.made += source.made;
    target.attempts += source.attempts;
    set_pc(target);
    return target;
}